'use strict'

const Promise = require('bluebird')

const mysqlCfg = require('../config').wechat.mysql

Promise.promisifyAll(require("mysql/lib/Pool").prototype)

var pool = require('mysql').createPool(mysqlCfg)
pool.queryOneAsync = function(sql,args) {
  return new Promise(function(resolve,reject){
    pool.queryAsync(sql,args).then(function(rows){
      resolve(rows[0])
    })
  })
}
module.exports = pool